// 提交之前注释掉这行，带包名不能通过编译
package atcoder.abc234a;

import java.io.*;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StreamTokenizer st = new StreamTokenizer(br);
    PrintWriter pr = new PrintWriter(new OutputStreamWriter(System.out));

    private long readLong() throws IOException {
        st.nextToken();
        return (long) st.nval;
    }

    private int readInt() throws IOException {
        return (int) readLong();
    }

    private String readString() throws Exception {
        st.nextToken();
        return st.sval;
    }

    public static void main(String[] args) throws Exception {
        new Main().run();
    }


    private int f(int x) {
        return x*x + 2*x + 3;
    }
    private void run() throws Exception {
        int t = readInt();

        int res = f(f(f(t)+t) + f(f(t)));

        pr.println(res);
        pr.close(); // 必须有这句
        return;
    }
}
